home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
sortf237.zip
/
SORTF.DOC
< prev
next >
Wrap
Text File
|
1991-09-20
|
13KB
|
340 lines
SORTF File Sorting Utility
Version 2.37 - Sep 20, 1991
Index
-----
Purpose ................................... 1
Format ................................... 1
Remarks ...................................1
Options summary ........................... 2
Invoking from Quick Basic................... 3
Examples .................................. 4
Version history ........................... 5
Usage restrictions ........................ 6
Copyright (c) Vernon D. Buerg 1985-90. ALL RIGHTS RESERVED.
SORTF Command Version 2.37 Page 1
------------- Sep 20, 1991
Purpose: The SORTF program reads record data from a file, sorts the
records, and writes the data to another file.
Format:
SORTF [d:][path]fname[.ext] [d:][path]fname[.ext]
[/+nnnn[,len]] -or- [/-nnnn,[len]]
[/Lnnnn]
[/R] [/C] [/Q]
[/K] or [/X]
Remarks: Records are read from the input file, sorted, and written
to the output file.
Two types of records may be sorted:
1) logical records. Each record ends with a carriage
| return and line feed, and may be up to 8192 characters
in length.
2) fixed length records. Each record is of length L as
defined by the '/Lnnnn' parameter. The records may
contain any kind of data, including carriage return,
line feed, and end-of-file without effecting the record
| length. The maximum record is 8192 bytes.
The sort order is in ascending ASCII character sequence.
You may supply the /R parameter to reverse the sort order
for all fields, or supply /- parameters for each key field
to be sorted in reverse order. The key fields are
processed from left to right as supplied in the command
line.
The /C option may be added to cause SORTF to treat the key
fields as case insensitive data. That is, lower case
letters in the key field are treated as upper case letters.
You may supply up to sixteen key offsets and lengths by
using the /+ or /- parameter, one for each key position and
its length. If /+ and /- are omitted, the key is taken
from the first character position for a length of 11.
| The position 'nnnn' may be a value from one to 8192.
| The key length 'len' may be a value from 1 to 8192. The /+
operand specifies that the specified key is sorted in
ascending order. The /- specifies desending sort order for
that key.
Use the /Q option to suppress the display of informational
messages. Error messages can not be suppressed.
SORTF Command OPTIONS SUMMARY Version 2.37 Page 2
------------- Sep 20, 1991
/C specifies that the keys are case insensitive; if
supplied, all lower case characters in the key fields
are converted to upper case for the purposes of
sorting.
/R sort in reverse order; over-rides any /- options and
treats them all as /+ options.
/Q suppress informational messages.
/K creates an output file that consists of sorted key data
which includes a 5-byte information prefix.
/X like /K, except that the 5-byte information prefix is
omitted, and a cr/lf (carriage return and line feed)
is added to each record.
/L specifies the sorting of fixed length records
/+ defines the location and length of a key field to be
sorted in ascending order
/- defines the location and length of a key field to be
sorted in descending order
SORTF Command INVOKING FROM QUICK BASIC Version 2.37 Page 3
------------- Sep 20, 1991
To invoke SORTF from a Quick Basic program, you can use either
the SHELL or CALL statements. Use of SHELL is straightforward.
Use of CALL requires that you include SORTF.OBJ when you LINK
your QB program.
You need to make memory available to SORTF from your QB
program. For QB version 3 and earlier, you can use the LINK
'/CP:nnnn' option. For QB 4 and later, I don't know how you
release memory. For BC 7, you can use the SETMEM function.
In the QB program : CALL SORTF ("test.fil new.fil /+1,12")
-or- SHELL "sortf test.fil new.fil /+1,12"
For CALL: LINK qbprogram + SORTF /CP:5000;
The /CP:5000 option will limit the QB program to 80K plus the
size of its code, data and stack. Whatever is left can be used
by CALLed programs. That amount will be about 120K less than
the DOS available memory.
For BC 7, here's an example of using SETMEM to release memory:
M1&=Setmem(0) ' Get heap size
M2&=Setmem(-M1&+128000) ' Release all but 128k
Call SORTF (" "+infile$+" "+outfile+" /options")
M3&=Setmem(M1&) ' Re-allocate all to heap
SORTF Command EXAMPLES Version 2.37 Page 4
------------- Sep 20, 1991
o to sort a file in descending order with the keys in
position 10:
SORTF TEST.DAT TEST.SRT /R/+10
o to sort the same file using keys with 24 characters:
SORTF TEST.DAT TEST.SRT /R/+10,24
o to sort a file of fixed length, binary records; the input
file contains records of 18 bytes each, the key is two
bytes at position 17 in each record in descending
order, and 11 bytes at postion 1 in ascending order:
SORTF SRTCATS.RND SRTCATS.IND /L18 /-17,2 /+1,12
o to sort on different keys, but creating an an output file
with the keys only:
SORTF TEST.DAT TEST.KEYS /-10,2 /+20,4 /-16,3 /K
Note the use of /-. It specifies that the first and third
keys are sorted in descending order, the second key is
sorted in ascending order.
The format of the keys-only file using /K is:
Offset Length Contents
------ ------ ------------------------------------------
0 2 Length of data record excluding CR and LF
2 3 Offset to record in input file
+0 hi-byte of 3-byte address offset
+1 low word of address offset
5 n Variable key data, depends on key definitions
The format of the keys-only file using /X is:
Offset Length Contents
------ ------ ------------------------------------------
0 n Variable key data, depends on key definitions
n 2 Carriage return and line feed
In the example above, the variable key data format is:
5 2 Data in records at offset 10
7 4 Data in records at offset 20